package main

import (
	"fmt"
	"log"
	"os"
	"strings"

	"db"

	_ "github.com/go-sql-driver/mysql"
)
func main() {

	log.Println("请输入：user:pwd@tcp(serverIP:serverPort)/databaseName")
	db.DataSourceName = writeParam(db.DataSourceName)

	log.Println("生成数据字典开始...")


	dictionary := getCurrentDirectory() + "/dictionary.MD"
	db.CreateDictionary(dictionary)
	log.Printf("生成数据字典完成 ==> %s", dictionary)

}

// 取得输入的参数
func writeParam(param string) string {
	_, err := fmt.Scanln(&param)
	if err == nil {
		return param
	} else {
		return ""
	}
}

// 取得当前路径
func getCurrentDirectory() string {
	var currentDir string
	currentDir, err := os.Getwd()
	if err != nil {
		log.Fatalln(err)
	}
	return strings.Replace(currentDir, "\\", "/", -1)
}

